let state = {
    subjectInfo: {},
    role: null,
    visit: null,
    mode: 0,
    audits: [],
    table: null,
    version: 0,
    stateOptions: ['', '草稿', '审核中'],
    frozenOptions: ['', '未冻结', '冻结'],
    relations: [
      {
        code: 'CRA',
        type: '2',
        alias: 'cra',
      },
      {
        code: 'DM',
        type: '3',
        alias: 'dm',
      },
      {
        code: 'PM',
        type: '6',
        alias: 'pm',
      },
      {
        code: 'Medical',
        type: '4',
        alias: 'mm',
      },
      {
        code: 'Site_PI',
        type: '5',
        alias: 'pi',
      },
    ],
    priority: [],
  },
  getters = {
    findRole: function (state) {
      if (!state.role) {
        let selectEdcRole = localStorage.getItem('projectRoleCode')
        state.role = selectEdcRole
      }
      return state.role
    },
    isWriteRole: function (state) {
      if (!state.role) {
        let selectEdcRole = localStorage.getItem('projectRoleCode')
        state.role = selectEdcRole
      }
      return state.role
    },
  },
  mutations = {
    clear(state) {
      state.subjectInfo = {}
      state.role = null
      state.visit = null
      state.mode = 0
      state.audits = []
      state.table = null
      state.version = 0
      state.priority = []
    },
    setSubjectInfo(state, subjectInfo) {
      state.subjectInfo = subjectInfo
    },
    setVisit(state, visit) {
      state.visit = visit
    },
    setMode(state, mode) {
      state.mode = mode
    },
    setAudits(state, audits) {
      state.audits = audits
    },
    setTable(state, table) {
      state.table = table
    },
    upgrade(state) {
      state.version = ++state.version
    },
    setPriority(state, priority) {
      state.priority = priority
    },
  },
  actions = {}
export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions,
}
